home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: undergrad.math.uwaterloo.ca!clgonsal
- From: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves)
- Subject: Re: Tradition or what?
- Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
- Message-ID: <Dn4wML.5LJ@undergrad.math.uwaterloo.ca>
- Date: Wed, 21 Feb 1996 16:32:44 GMT
- References: <4g0elg$mdr@redstone.interpath.net>
- Nntp-Posting-Host: cayley.uwaterloo.ca
- Organization: University of Waterloo
-
- In article <4g0elg$mdr@redstone.interpath.net>,
- Scott McMahan - Softbase Systems <softbase@mercury.interpath.net> wrote:
- >Erik van Renselaar writes:
- >
- >: Can anyone tell me what the use is of returning
- >: the same value for the function and one of the
- >: output parameters, like it is done in strcpy?
- >
- >Steve Maguire discusses this issue in Writing Solid Code. The
- >randomness with which the C library's parameters and return code
- >(0=success AND failure depending on the function!) conventions happened
- >are bad because they influence people who look upon them as models.
- >Reading Writing Solid Code is almost mandatory.
-
- I read both "Writing Solid Code" and "Code Complete". I found Code
- Complete to be much better, and it covered a lot of the same stuff as
- Writing Solid Code. Most of what CC didn't cover that WSC did cover I
- found to be either obvious, or silly. It was also interesting to note that
- there are some points on which the two authors are diametrically opposed.
-
- The inconsistent return types/parameters of the ANSI C library are pretty
- obvious simply because they're so annoying. The most irritating example I
- can think of is the stdio functions that take a FILE*. Most take it as the
- first parameter, but a few take it as the *last* parameter. Argh!
-
- As for strcpy, etc, returning the same pointer you pass them, this might
- also be useful for writing code in a "lisp-like" way. For instance:
-
- strcat( strcpy( a, b ), c );
-
- This copies b to a and that concatenates c onto the end of a. Certainly not
- recommended unless you're absolutely positive you're not going to get a
- NULL in there somewhere.
-
- --
- Carl Laurence Gonsalves - clgonsal@undergrad.math.uwaterloo.ca
- Computer Science, University of Waterloo
- http://www.undergrad.math.uwaterloo.ca/~clgonsal/
- http://www.csclub.uwaterloo.ca/~clgonsal/
-